/* GUI CONVERTED from rwemmt.p (converter v1.76) Wed Feb 27 08:35:40 2002 */
/* rwemmt.p - ACTUAL PAY RATE MAINTENANCE                               */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.6.1.6 $                                                         */
/*V8:ConvertMode=Maintenance                                            */
/* REVISION: 1.0     LAST MODIFIED: 02/10/88    BY: jms                     */
/* REVISION: 7.3     LAST MODIFIED: 02/22/93    BY: ram *G720*              */
/* Oracle changes (share-locks)     09/13/94    BY: rwl *GM49*              */
/* REVISION: 7.3     LAST MODIFIED: 01/30/97    BY: rxm *G2KQ*              */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane        */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan       */
/* REVISION: 8.6E     LAST MODIFIED: 08/06/98   BY: *J2VN* Santhosh Nair    */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan       */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N0F1* Jean Miller      */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb              */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* $Revision: 1.6.1.6 $    BY: Anitha Gopal          DATE: 01/11/02  ECO: *N17G*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/*  DISPLAY TITLE  */
{mfdtitle.i "b+ "}
{pxmaint.i}

define variable del-yn like mfc_logical initial no.
define variable err_flag as logical no-undo.

/*  DISPLAY FORM  */

/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
emp_addr       colon 20
   emp_lname      colon 20
   emp_fname      colon 52
   emp_line1      colon 20
   emp_line2      colon 20
   emp_city       colon 20
   emp_state      colon 52
   emp_zip        colon 65
   emp_country    colon 20
   emp_ctry       colon 53 no-label
   emp_phone      colon 20
   emp_bs_phone   colon 20
   emp_ext        colon 42
   skip(1)
   emp_ssn        colon 20
   emp_birthday   colon 57

 SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
emp_title      colon 20
   emp_shift      colon 63
   emp_emp_date   colon 20
   emp_units      colon 63
   emp_trm_date   colon 20
   emp_pay_type   colon 63
   emp_dept       colon 20
   emp_pay_rate   colon 63
   emp_project    colon 20
   emp_last_dt    colon 63
   emp_status     colon 20
   emp_last_pay   colon 63
 SKIP(.4)  /*GUI*/
with frame b side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-b-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame b = F-b-title.
 RECT-FRAME-LABEL:HIDDEN in frame b = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame b =
  FRAME b:HEIGHT-PIXELS - RECT-FRAME:Y in frame b - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME b = FRAME b:WIDTH-CHARS - .5.  /*GUI*/


/* SET EXTERNAL LABELS */
setFrameLabels(frame b:handle).

/*  DISPLAY  */
view frame a.
view frame b.

mainloop:
repeat:
/*GUI*/ if global-beam-me-up then undo, leave.


   do transaction:
/*GUI*/ if global-beam-me-up then undo, leave.


      prompt-for emp_addr
      with frame a
      editing:

         /*  FIND NEXT/PREVIOUS RECORD  */
         {mfnp.i
            emp_mstr
            emp_addr
            emp_addr
            emp_addr
            emp_addr
            emp_addr}
         if recno <> ?
         then do:
            display
               emp_addr
               emp_lname
               emp_fname
               emp_line1
               emp_line2
               emp_city
               emp_state
               emp_zip
               emp_country
               emp_ctry
               emp_phone
               emp_bs_phone
               emp_ext
               emp_ssn
               emp_birthday
            with frame a.
            clear frame b.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame b = F-b-title.
         end. /* IF recno <> ? */
      end. /* EDITING */

      /*  ADD/MOD/DELETE  */
      if input emp_addr = ""
      then do:
         /* INVALID EMPLOYEE CODE */
         {pxmsg.i &MSGNUM=4006 &ERRORLEVEL=3}
         undo mainloop.
      end. /* IF input emp_addr = "" */

      clear frame b.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame b = F-b-title.

      find emp_mstr
         using emp_addr
         no-error.
      if not available emp_mstr
      then do:
         /* ADDING NEW RECORD */
         {pxmsg.i &MSGNUM=1 &ERRORLEVEL=1}
         create emp_mstr.
         assign
            emp_addr.
      end. /*  IF NOT AVAILABLE emp_mstr */

      /* STORE MODIFY DATE AND USERID */

      assign
         emp_mod_date = today
         emp_userid   = global_userid
         recno        = recid(emp_mstr)
         ststatus     = stline[2].

      status input ststatus.
      del-yn = no.

      loopa:
      do on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.


         display
            emp_addr
            emp_country
         with frame a.

         update
            emp_lname
            emp_fname
            emp_line1
            emp_line2
            emp_city
            emp_state
            emp_zip
            emp_ctry
            emp_phone
            emp_bs_phone
            emp_ext
            emp_ssn
            emp_birthday
            go-on("F5" "CTRL-D" )
         with frame a.

         /* VALIDATE COUNTRY CODE */

         err_flag = yes.
         do while err_flag:

            {pxrun.i &PROC='validateCountryCode'
                     &PROGRAM='adadxr.p'
                     &PARAM="(input emp_ctry)"
                     &NOAPPERROR=True
                     &CATCHERROR=True
            }

            if return-value <> {&SUCCESS-RESULT}
            then
               update
                  emp_ctry
               with frame a.

            else do:
               {pxrun.i &PROC='getCountryDescription'
                        &PROGRAM='adctxr.p'
                        &PARAM="(input  emp_ctry,
                                 output emp_country)"
                        &NOAPPERROR=True
                        &CATCHERROR=True
               }

               if return-value = {&SUCCESS-RESULT}
               then do:
                  display
                     emp_country
                  with frame a.
                  err_flag = no.
               end. /* IF return-value = {&SUCCESS-RESULT} */

            end. /* ELSE DO */
         end. /* DO WHILE err_flag */

         /*  DELETE  */
         if lastkey = keycode("F5")
            or lastkey = keycode("CTRL-D")
         then do:
            del-yn = yes.
            /* CONFIRM DELETE */
            {pxmsg.i &MSGNUM=11 &ERRORLEVEL=1 &CONFIRM=del-yn}
            if del-yn = no
            then
               undo loopa.
         end. /*  IF lastkey = keycode("F5") */

         if del-yn
         then do:

            /* OK TO DELETE */

            delete
               emp_mstr.
            clear frame a.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
            del-yn = no.
            next mainloop.
         end. /* IF del-yn */

         else do:
            err_flag = yes.
            do while err_flag:
               if emp_ssn = ""
               then do:
                  /* SSN SHOULD NOT BE BLANK */
                  {pxmsg.i &MSGNUM=4056 &ERRORLEVEL=3}

                  update
                     emp_ssn
                  with frame a.
               end. /* IF emp_ssn = "" */
               else
                  err_flag = no.
            end. /* DO WHILE err_flag */

            ststatus = stline[3].
            status input ststatus.

            /* MODIFY JOB AND PAY INFORMATION */

            loopb:
            do on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.


               update
                  emp_title
                  emp_emp_date
                  emp_trm_date
                  emp_dept
                  emp_project
                  emp_status
                  emp_shift

                  emp_units
                  emp_pay_type
                  emp_pay_rate
                  emp_last_dt
                  emp_last_pay
               with frame b.

               err_flag = yes.
               do while err_flag:
                  if lookup(emp_status,"AC,TR,LA,PT") = 0
                  then do:
                     /* INVALID STATUS CODE */
                     {pxmsg.i &MSGNUM=4033 &ERRORLEVEL=3}

                     update
                        emp_status
                     with frame b.
                  end. /* IF lookup(emp_status,"AC,TR,LA,PT") = 0 */
                  else
                     err_flag = no.
               end. /* DO WHILE err_flag */

               err_flag = yes.
               do while err_flag:
                  if emp_dept = ""
                  then do:
                     /* DEPARTMENT CODE IS REQUIRED */
                     {pxmsg.i &MSGNUM=4046 &ERRORLEVEL=3}

                     update
                        emp_dept with frame b.
                  end. /*  IF emp_dept = "" */
                  else
                     err_flag = no.
               end. /*  DO WHILE err_flag */

            end.
/*GUI*/ if global-beam-me-up then undo, leave.
  /* LOOPB */
         end.  /* ELSE DO */
      end.
/*GUI*/ if global-beam-me-up then undo, leave.
  /* LOOPA */
   end.
/*GUI*/ if global-beam-me-up then undo, leave.
  /* DO TRANSACTION */
end.
/*GUI*/ if global-beam-me-up then undo, leave.
  /* MAINLOOP */

status input.
